<?php if ($_username){?>			
		<div id="subnavi">
			<h2><?=t("Meine Server")?></h2>
			<ul><?php 
			$set = MINE_server_list($_username);
			while( list ( $key, $val ) = each ( $set ) ){
				echo "<li class='".($val["id"]==$_GET["id"]?"select":"norm")."'><a href='main.php?load=edit_server&id=".$val["id"]."' >".$val["name"]."</a></li>";
			}
			?>
			<li class="<?=(!$_GET["id"])?"select":"norm"?>"><a href="main.php?load=edit_server"><i>-> <?=t("Neuer Server")?></i></a></li>
			</ul>
		</div>
<?php }?>
<div id="content">
<?php


if ($_POST["url"]){
	if (!isset($_GET["id"])){
		$id = false;
	}else{
		$id = $_GET["id"];
	}
	
	if (substr($_POST["link"],0,4) <> 'http')
		$_POST["link"] = "http://".$_POST["link"];
	
	$data["name"] 	= $_POST["name"];
	$data["url"] 	= $_POST["url"];
	$data["page"]	= $_POST["page"];
	$data["land"]	= $_POST["land"];
	
	$data["mode"]	= $_POST["mode"];
	
	$data["verw"]	= $_POST["verw"];
	$data["kampf"]	= $_POST["kampf"];
	$data["monster"]= $_POST["monster"];
	$data["tiere"]	= $_POST["tiere"];
	$data["freib"]	= $_POST["freib"];
	$data["offmode"]= $_POST["offmode"];
	$data["version"]= $_POST["version"];
	$data["link"]	= $_POST["link"];
	
	$data["rss"]	= $_POST["rss"];
	$data["logo"]	= $_POST["logo"];
	$data["text2"]	= $_POST["text2"];
	$data["galerie"]= $_POST["galerie"];
	
	
	MINE_server_update($id, $data);?>
		<?=t("Es wird gespeichert")?>. . .<br />
		<script type="text/javascript">
		 <!--
		 setTimeout('window.document.location.href = "http://<?=$_SERVER["SERVER_NAME"].$_t.$_SERVER["SCRIPT_NAME"]?>?<?=$_SERVER["QUERY_STRING"]?>";',3000);
		 //–>
		 </script>
		 <br />
		 <img src='img/spin.gif'/>
		 <br /><br />
		<?=t("Wenn es nicht weiter geht bitte <a href='user.html'>hier</a> klicken.")?>
	
	<?php 
}else{
	if ($_GET["id"]){
		if (!MINE_server_is_addmin($_GET["id"],$_username)){
			echo t("Sie haben keine Berechtigung für diesen Server!");
			die('');
		}
		$server = MINE_server_detail($_GET["id"]);
		$d = $server["server"];
	}else{
		$d = array();
	} 
	
	if ($d['mode'] == "l"){
		echo "<h2>".t("Dieser Server wurde vom Administrator gesperrt!")."</h2>";
	}else{
	
	
	if (!isset($d["land"]))
		$d["land"] = isset($_SESSION["lang"])?$_SESSION["lang"]:'de';
		
	function slector($id){
		global $d;
		return "<select name='$id'>
			  <option value=t ".($d[$id]=='t'?"selected":"").">".t('Ja')."</option>
			  <option value=f ".($d[$id]=='f'?"selected":"").">".t("Nein")."</option>
		</select>";
	}
	?>
	<form method=post>
		<table>
		<tr><td><?=t("Name:")?> 				</td><td><input size=40 name=name value='<?=$d["name"]?>' /></td></tr>
		<tr><td><?=t("Adresse:")?> 				</td><td><input size=40 name=url value='<?=$d["url"]?>' /></td></tr>
		<tr><td><?=t("Server Version:")?> 		</td><td><input size=40 name=version value='<?=$d["version"]?>' /></td></tr>
		<tr><td><?=t("Webseite:")?> 			</td><td><input size=40 name=link value='<?=$d["link"]?>' /></td></tr>
		<tr><td><?=t("RSS Feed:")?> 			</td><td><input size=40 name=rss value='<?=$d["rss"]?>' /></td></tr>
		<tr><td><?=t("URL zum Logo:")?> 		</td><td><input size=40 name=logo value='<?=$d["logo"]?>' /></td></tr>
		</table><table>
		
		<tr><td><?=t("Den Server:")?></td><td>
			<select name='mode'>
				  <option value=1 <?=$d['mode']=='1'?"selected":""?>><?=t('Anzeigen')?></option>
				  <option value=h <?=$d['mode']=='h'?"selected":""?>><?=t('Verstecken')?></option>
			</select>
			</td></tr>
		
		<tr><td><?=t("Land")?>		</td><td><select name='land'><?php
			$set = $handle = scandir('img/flags');
			while( list ( $key, $val ) = each ( $set ) ){
				if ($val[0] <> '.'){
					echo "<option ".(substr($val,0,-4)==$d["land"]?"selected":"").">".substr($val,0,-4)."</option>";
				}
			}
		?></select></td></tr>
		
		<tr><td><?=t("Verwundbar?")?>						</td><td><?=slector('verw')?></td></tr>
		<tr><td><?=t("Kann man sich bekämfen?")?>			</td><td><?=slector('kampf')?></td></tr>
		<tr><td><?=t("Gib es Monster?")?>					</td><td><?=slector('monster')?></td></tr>
		<tr><td><?=t("Gib es Tiere?")?>						</td><td><?=slector('tiere')?></td></tr>
		<tr><td><?=t("Kann jeder mitbaun?")?>				</td><td><?=slector('freib')?></td></tr>
		<tr><td><?=t("Ist der Server im Offline-Mode?")?>	</td><td><?=slector('offmode')?></td></tr>		
		</table>		
		<div style='float: left;'><?=t("Kurze <br />Beschreibung:")?></div>
		 <textarea id='mce' name=page cols="40" rows="8"><?=$d["page"]?></textarea><br />
</div>
<div id="content" style="width: 650px;">		 
		<?=t("Ausführliche Beschreibung:")?><br /> <textarea id='mce2' name=text2 cols="80" rows="10"><?=$d["text2"]?></textarea><br />
		
		<div style='float: left;'><?=t("Bilder <br />vom Server:<br /><br /> (eine URL <br /> je Zeile)")?></div>
		 <textarea id='mce' name=galerie cols="70" rows="8"><?=$d["galerie"]?></textarea><br />
		<h2>Buttens:</h2>
		<?php if (!isset($d["id"])){
			echo t("Die Buttens sind erst <u>nach</u> dem Speichern verfügbar")."<br />";
		}else{?>
		<table><tr><th></th><th>HTML</th><th>BBC</th></tr><tr>
		<td>
		<a href="http://mcpiraten.info/<?=$d["id"]?>c" ><img src="img/p1.png" /></a>
		</td><td><input value='<a href="http://mcpiraten.info/<?=$d["id"]?>c" ><img src="http://mcpiraten.info/img/p1.png" /></a>' />
		</td><td><input value='[url=http://mcpiraten.info/<?=$d["id"]?>c][img]http://mcpiraten.info/img/p1.png[/img][/url]' />
		</td></tr><tr><td>
		<a href="http://mcpiraten.info/<?=$d["id"]?>c" ><img src="img/p1_2.png" /></a>
		</td><td><input value='<a href="http://mcpiraten.info/<?=$d["id"]?>c" ><img src="http://mcpiraten.info/img/p1_2.png" /></a>' />
		</td><td><input value='[url=http://mcpiraten.info/<?=$d["id"]?>c][img]http://mcpiraten.info/img/p1_2.png[/img][/url]' />
		</td></tr><tr><td>
		<a href="http://mcpiraten.info/<?=$d["id"]?>c" ><img src="img/p1_4.png" /></a>
		</td><td><input value='<a href="http://mcpiraten.info/<?=$d["id"]?>c" ><img src="http://mcpiraten.info/img/p1_4.png" /></a>' />
		</td><td><input value='[url=http://mcpiraten.info/<?=$d["id"]?>c][img]http://mcpiraten.info/img/p1_4.png[/img][/url]' />
		</td></tr></table>
		<?=t('Kurtze URL:')?> <a>http://mcpiraten.info/<?=$d["id"]?></a>
		<br />
		<?php }?>
		<br />
		<input type=submit value='<?=t("Speichern")?>' />
	</form><?php
	} 
}